$(function() {
	$('#fileupload').fileupload({
		dataType : 'json',
		add : function(e, data) {
			$.each(data.files, function(index, file) {
				$('#filetable').append('<tr><td>' + file.name + '</td>');
				$('#filetable').append('<td id="progress_"' + file.name + ' class="bar" style="width: 0%"</td></tr>');
			})
			data.submit();
		},
		done : function(e, data) {
			$('#progress .bar').html('100%')
			$('#progress .bar').css('width', '100%');
		},
		progress : function(e, data) {
			var progress = parseInt(data.loaded / data.total * 100, 10);
			$.each(data.files, function(index, file) {
				$('#progress_' + file.name + ' .bar').css('width', progress + '%');
			})
		}
	});
});
